package com.hou.springmq.controller;

import com.hou.springmq.mq.producer.queue.QueueSender;
import com.hou.springmq.mq.producer.topic.TopicSender;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/mq")
public class ActiveMQController {

    //注入发送类
    @Autowired
    private QueueSender queueSender;
    @Autowired
    private TopicSender topicSender;
    //测试方法
    @RequestMapping(value = "/test", method = RequestMethod.GET)
    @ResponseBody
    public String test01(){
        System.out.println("----------");
        return "houzheng";
    }
    //发送队列
    @ResponseBody
    @RequestMapping("/sendQueue")
    public String sendQueue(@RequestParam("message")String message){
        //消息发送到指定的queue
        queueSender.send("queue",message);
        return "suc";
    }
    //发送主题
    @ResponseBody
    @RequestMapping("/sendTopic")
    public String sendTopic(@RequestParam("message")String message){
        topicSender.send("topic",message);
        return "suc";
    }
}
